

import java.io.File;
import java.io.IOException;
import java.util.Map;
import java.util.ResourceBundle;

import org.weso.lodin.appserv.DatasetAppServ;
import org.weso.lodin.generated.Indicator;
import org.weso.lodin.to.DatasetTO;
import org.weso.lodin.utils.PrefixManager;

import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.ModelFactory;


public class DatasetsAppServMain {

	public static void main(String []args) throws IOException{
		DatasetAppServ transformer = new DatasetAppServ();
		ResourceBundle mapPrefixesURIs = PrefixManager.getResourceBundle();		
		Map<DatasetTO, Model> datasetsModels = transformer.transformIndicatorsDAO();
		boolean allIn = Boolean.TRUE;
		String outputFile = "all-indicators.ttl";
		if(allIn){
			Model result = ModelFactory.createDefaultModel();
			for(Model m:datasetsModels.values()){
				result.add(m);
			}
			//TransformerAppServMain.addPrefixes(result, mapPrefixesURIs);
			//result.write(System.out);
			IndicatorsAppServMain.serializeModel(result,mapPrefixesURIs,IndicatorsAppServMain.DIR_GENERATED+File.separator+outputFile);
		}else{
			for(DatasetTO indicator:datasetsModels.keySet()){
				IndicatorsAppServMain.serializeModel(datasetsModels.get(indicator),mapPrefixesURIs, 
						indicator.getCode()+".ttl");	
			}		
			
		}
		
	}

}

